home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-07-27 | 3.5 KB | 141 lines | [TEXT/MMCC] |
- /*
- Copyright © 1993,1994 by Fabrizio Oddone
- ••• ••• ••• ••• ••• ••• ••• ••• ••• •••
- This source code is distributed as freeware: you can copy, exchange, modify this
- code as you wish. You may include this code in any kind of application: freeware,
- shareware, or commercial, provided that full credits are given.
- You may not sell or distribute this code for profit.
- */
-
-
- //#pragma load "MacDump"
-
- #include "Utils6.h"
-
- #if !defined(powerc) && !defined (__powerc)
-
- typedef struct {
- FSSpec destFile;
- ScriptCode theScript;
- } StdFileResult, *StdFileResultPtr;
-
- #if !defined(FabNoSegmentDirectives)
- #pragma segment Registration
- #endif
-
- short FabFSpOpenResFile(const FSSpec *spec,char permission)
- {
- long Gresp;
- register Boolean flag = false;
-
- if (Gestalt(gestaltFSAttr, &Gresp) == noErr)
- if (Gresp & (1L << gestaltHasFSSpecCalls))
- flag = true;
-
- return (flag ?
- FSpOpenResFile(spec, permission) :
- HOpenResFile(spec->vRefNum, spec->parID, spec->name, permission));
- }
-
- OSErr FabFSpOpenDF(const FSSpec *spec,char permission,short *refNum)
- {
- long Gresp;
- register Boolean flag = false;
-
- if (Gestalt(gestaltFSAttr, &Gresp) == noErr)
- if (Gresp & (1L << gestaltHasFSSpecCalls))
- flag = true;
-
- return (flag ?
- FSpOpenDF(spec, permission, refNum) :
- HOpen(spec->vRefNum, spec->parID, spec->name, permission, refNum));
- }
-
- OSErr FabFSpCreate(const FSSpec *spec,OSType creator,OSType fileType, ScriptCode scrTag)
- {
- long Gresp;
- register Boolean flag = false;
-
- if (Gestalt(gestaltFSAttr, &Gresp) == noErr)
- if (Gresp & (1L << gestaltHasFSSpecCalls))
- flag = true;
-
- return (flag ?
- FSpCreate(spec, creator, fileType, scrTag) :
- HCreate(spec->vRefNum, spec->parID, spec->name, creator, fileType));
- }
-
- OSErr FabFSpDelete(const FSSpec *spec)
- {
- long Gresp;
- register Boolean flag = false;
-
- if (Gestalt(gestaltFSAttr, &Gresp) == noErr)
- if (Gresp & (1L << gestaltHasFSSpecCalls))
- flag = true;
-
- return (flag ?
- FSpDelete(spec) :
- HDelete(spec->vRefNum, spec->parID, spec->name));
- }
-
- void FabStandardGetFile(FileFilterUPP fileFilter, short numTypes, SFTypeList typeList,
- StandardFileReply *reply)
- {
- Point mypt = {90, 10};
- long Gresp;
- register Boolean flag = false;
-
- if (Gestalt(gestaltStandardFileAttr, &Gresp) == noErr)
- if (Gresp & (1L << gestaltStandardFile58))
- flag = true;
-
- if (flag) {
- StandardGetFile(fileFilter, numTypes, typeList, reply);
- }
- else {
- SFReply myOldReply;
-
- SFGetFile(mypt, nil, fileFilter, numTypes, typeList, nil, &myOldReply);
- reply->sfGood = myOldReply.good;
- // reply->sfReplacing = false;
- reply->sfType = myOldReply.fType;
- reply->sfFile.vRefNum = myOldReply.vRefNum;
- reply->sfFile.parID = LMGetCurDirStore();
- (void) PLstrcpy(reply->sfFile.name, myOldReply.fName);
- reply->sfScript = smCurrentScript;
- }
- }
-
- void FabStandardPutFile(ConstStr255Param prompt,
- ConstStr255Param defaultName,
- StandardFileReply *reply)
- {
- Point mypt = {90, 10};
- long Gresp;
- register Boolean flag = false;
-
- if (Gestalt(gestaltStandardFileAttr, &Gresp) == noErr)
- if (Gresp & (1L << gestaltStandardFile58))
- flag = true;
-
- if (flag) {
- StandardPutFile(prompt, defaultName, reply);
- }
- else {
- SFReply myOldReply;
-
- SFPutFile(mypt, prompt, defaultName, nil, &myOldReply);
- reply->sfGood = myOldReply.good;
- reply->sfReplacing = false;
- reply->sfType = myOldReply.fType;
- reply->sfFile.vRefNum = myOldReply.vRefNum;
- reply->sfFile.parID = LMGetCurDirStore();
- (void) PLstrcpy(reply->sfFile.name, myOldReply.fName);
- reply->sfScript = smCurrentScript;
- }
- }
-
- #endif
-
-